import axios from 'axios'

const baseURL = process.env.VUE_APP_BASEURL

const instance = axios.create({
  baseURL
  // withCredentials: false
})

instance.interceptors.response.use(
  (response) => {
     console.log(response)

    const {
      result
      // errorMsg
    } = response.data

    if (result === 1) {
      return response.data
    } else {
      return Promise.reject(response.data)
    }
    // if (result === 0) {
    // if (errorMsg) {
    //   return Promise.reject(errorMsg)
    // } else {
    //   return response
    // }
    // }
  }
  // (error) => {
  //   return Promise.reject(error.message)
  // }
)

export default instance
